package hiho.ku._1061;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.valueOf(br.readLine());
		for (int i = 0; i < t; i++)
			run(br);
	}
	
	private static void run(BufferedReader br) throws NumberFormatException, IOException {
		int c = Integer.valueOf(br.readLine());
		if (c <= 0) {
			br.readLine();
			System.out.println("NO");
			return;
		}
		
		List<Integer> s = new ArrayList<Integer>();
		List<Integer> f = new ArrayList<Integer>();
		int now = br.read();
		int count = 1;
		for (int i = 1; i < c; i++) {
			int next = br.read();
			if (next == now)
				count++;
			else {
				s.add(now);
				f.add(count);
				now = next;
				count = 1;
			}
		}
		s.add(now);
		f.add(count);
		br.readLine();
		
		boolean check = false;
		for (int i = 0; i <= s.size() - 3; i++)
			if (f.get(i) >= f.get(i + 1) && f.get(i + 1) <= f.get(i + 2) && s.get(i) == s.get(i + 1) - 1 && s.get(i + 1) == s.get(i + 2) - 1) {
				check = true;
				break;
			}
		if (check)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}
